<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html-el" prefix="html-el" %>
<%@taglib uri="http://struts.apache.org/tags-bean-el" prefix="bean-el" %>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@taglib uri="http://struts.apache.org/tags-logic-el" prefix="logic-el" %>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@taglib uri="/WEB-INF/tld/application.tld" prefix="app" %>

<html-el:form action="/conferenciaCaixa.do?method=iniciar">
	<html-el:hidden property="method" styleId="method"/>
	<html-el:hidden property="dataMovimento" styleId="dataMovimento"/>
	
	<!-- TABLE CENTER -->
	<table style="width: 100%">
		<tr>
			<td align="center" valign="top">
				<!-- CONTENT -->			
				<div class="content">
					<table class="con">
						<tr>
							<td valign="top">
								<table class="breadory">
									<tr>
										<td>Conferência de Caixa</td>
									</tr>
								</table>
							
								<table style="width:750px">
									<tr>
										<td style="padding-top:5px"></td>
									</tr>
									<tr>
										<td class="label" style="width:40px">Data:</td>
										<td style="text-align: left">
											<input type="text" id="data" value="${dataDojo}" style="font-size:14px;width:110px" title="Data Vencimento" onchange="consultar()" constraints="{datePattern:'dd/MM/yyyy', strict:true}" data-dojo-type="dijit.form.DateTextBox" data-dojo-props="required:true, invalidMessage:'Data Inválida!'" />
										</td>
									</tr>
									<tr>
										<td style="padding-top:5px"></td>
									</tr>
									<tr>
										<td valign="top" colspan="2">
											<table style="width: 100%" class="tbDadosConsulta">
												<tr>
													<th style="width:25px"></th>
													<th>Descrição</th>
													<th style="width:110px">Horário</th>
													<th style="width:110px">Tipo</th>
													<th style="width:90px">Valor</th>
													<th style="width:90px">Banco</th>
												</tr>
												<logic:present name="recebidos" scope="request">
													<logic-el:iterate id="bean" name="recebidos" scope="request" indexId="i">
														<tr class="linha${i%2}">
															<td style="text-align: center">${i+1}</td>
															<td style="text-align: left">${bean.descricao}</td>
															<td style="text-align: center">
																<bean:write name="bean" property="ordemServicoEspecie.ordemServico.cadastro" format="HH:mm"/>
															</td>
															<td style="text-align: center">${bean.ordemServicoEspecie.formaPagamento.descricao}</td>
															<td style="text-align: right">
																<bean:write name="bean" property="valorPagamento" format="###,##0.00" locale="defaultLocale"/>
															</td>
															<td style="text-align: center">
																<logic:equal name="bean" property="ordemServicoEspecie.formaPagamento.name" value="CHEQUE">
																		<app:bancoIcone src="${bean.ordemServicoEspecie.banco.icone}"/>																
																</logic:equal>
																<logic:notEqual name="bean" property="ordemServicoEspecie.formaPagamento.name" value="CHEQUE">-</logic:notEqual>
															</td>
														</tr>
													</logic-el:iterate>
													<tr>
														<td style="text-align: right" colspan="4"><b>Total:</b></td>
														<td style="text-align: right"><b>
															<bean:write name="total" format="###,##0.00" locale="defaultLocale"/>
														</b></td>
														<td style="text-align: center"></td>
													</tr>
												</logic:present>						
											</table>
										</td>
									</tr>
								</table>							
							</td>
						</tr>
						<logic:present name="recebidos" scope="request">
							<tr>
								<td style="height:20px"></td>
							</tr>
							<tr>
								<td valign="top" align="left">
									<table class="breadory" style="width:40%">
										<tr>
											<td style="padding-left: 5px" colspan="2">
												<table style="width: 100%">
													<tr>
														<td><b>- Dinheiro:</b>&nbsp;</td>
														<td style="text-align: right">
															<bean:write name="totalDinheiro" format="###,##0.00" locale="defaultLocale"/>
														</td>
													</tr>
													<tr>
														<td><b>- Cheque:</b>&nbsp;</td>
														<td style="text-align: right">
															<bean:write name="totalCheque" format="###,##0.00" locale="defaultLocale"/>
														</td>
													</tr>	
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</logic:present>					
					</table>	
				</div>	
			</td>
		</tr>
	</table>
</html-el:form>

<script type="text/javascript">

	function consultar() {
		document.getElementById("dataMovimento").value = document.getElementById("data").value;
		document.forms[0].submit();
	}

</script>